"use strict";
//装饰器组合
// 装饰器可以组合使⽤，执⾏顺序为：先【由上到下】的执⾏所有的装饰器⼯⼚，依次获取到装饰器，然后再【由下到上】执⾏所有的装饰器
//装饰器组合 —— 执⾏顺序
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
//装饰器
function test3(target) {
    console.log("装饰器1");
}
//装饰器工厂
function test4() {
    console.log("装饰器工厂2");
    return function (target) {
        console.log("装饰器2");
    };
}
//装饰器工厂
function test5() {
    console.log("装饰器工厂3");
    return function (target) {
        console.log("装饰器3");
    };
}
//装饰器
function test6(target) {
    console.log("装饰器4");
}
let Person18 = class Person18 {
};
Person18 = __decorate([
    test6,
    test5(),
    test4(),
    test3
], Person18);
//泛型约束 扩展方法
function LogTime2(target) {
    return class extends target {
        constructor(...args) {
            super(...args);
            this.createTime = new Date();
        }
        getTime() {
            return `该对象的创建时间为${this.createTime}`;
        }
    };
}
//扩展方法循环次数
function LogInfo3(n) {
    return function (target) {
        target.prototype.introduce = function () {
            for (let i = 0; i < n; i++) {
                console.log(`我的名字：${this.name}，我的年龄：${this.age}`);
            }
        };
    };
}
//扩展将对象转化为json字符串
function CustomDemo(target) {
    target.prototype.toString = function () {
        // console.log(this)
        return JSON.stringify(this);
    };
    // 封闭其原型对象，禁⽌随意操作其原型对象
    // Object.seal(target.prototype)
}
let Person19 = class Person19 {
    constructor(name, age) {
        this.name = name;
        this.age = age;
    }
    speak() {
        console.log('你好呀！');
    }
};
Person19 = __decorate([
    CustomDemo,
    LogInfo3(3),
    LogTime2
], Person19);
const p19 = new Person19('张三', 18);
console.log(p19.getTime());
console.log(p19.toString());
p19.introduce();
